package com.example.demo2_review.design_pattern.creational_patterns.factory_pattern;

import com.aliyun.oss.common.utils.StringUtils;

import static com.example.demo2_review.pojo.common.BaseConstants1.STR_CIRCLE;
import static com.example.demo2_review.pojo.common.BaseConstants1.STR_RECTANGLE;

/**
 * @Author zwp14
 * @create 2024/6/24 18:23
 * @description 模板工厂
 */
public class ShapeFactory {

    /**
     * 给出绘画类型，获取绘画工厂内容
     * @param shapeType 要求绘画类型
     * @return 绘画工厂内容
     */
    public ShapeService getShape(String shapeType) {
        if (StringUtils.isNullOrEmpty(shapeType)) {
            return null;
        }
        if (STR_CIRCLE.equalsIgnoreCase(shapeType)) {
            return new Circle();
        }
        if (STR_RECTANGLE.equalsIgnoreCase(shapeType)) {
            return new Rectangle();
        }
        return null;
    }
}
